package com.sys.SysSales.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.enums.BusinessType;
import com.sys.SysSales.domain.SysSalesInventory;
import com.sys.SysSales.service.ISysSalesInventoryService;
import com.sys.common.utils.poi.ExcelUtil;
import com.sys.common.core.page.TableDataInfo;

/**
 * 产品库存Controller
 * 
 * @author ruoyi
 * @date 2025-09-26
 */
@RestController
@RequestMapping("/SysSales/SysSalesInventory")
public class SysSalesInventoryController extends BaseController
{
    @Autowired
    private ISysSalesInventoryService sysSalesInventoryService;

    /**
     * 查询产品库存列表
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesInventory:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSalesInventory sysSalesInventory)
    {
        startPage();
        List<SysSalesInventory> list = sysSalesInventoryService.selectSysSalesInventoryList(sysSalesInventory);
        return getDataTable(list);
    }

    /**
     * 导出产品库存列表
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesInventory:export')")
    @Log(title = "产品库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSalesInventory sysSalesInventory)
    {
        List<SysSalesInventory> list = sysSalesInventoryService.selectSysSalesInventoryList(sysSalesInventory);
        ExcelUtil<SysSalesInventory> util = new ExcelUtil<SysSalesInventory>(SysSalesInventory.class);
        util.exportExcel(response, list, "产品库存数据");
    }

    /**
     * 获取产品库存详细信息
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesInventory:query')")
    @GetMapping(value = "/{inventoryId}")
    public AjaxResult getInfo(@PathVariable("inventoryId") Long inventoryId)
    {
        return success(sysSalesInventoryService.selectSysSalesInventoryByInventoryId(inventoryId));
    }

    /**
     * 新增产品库存
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesInventory:add')")
    @Log(title = "产品库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSalesInventory sysSalesInventory)
    {
        return toAjax(sysSalesInventoryService.insertSysSalesInventory(sysSalesInventory));
    }

    /**
     * 修改产品库存
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesInventory:edit')")
    @Log(title = "产品库存", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSalesInventory sysSalesInventory)
    {
        return toAjax(sysSalesInventoryService.updateSysSalesInventory(sysSalesInventory));
    }

    /**
     * 删除产品库存
     */
    @PreAuthorize("@ss.hasPermi('SysSales:SysSalesInventory:remove')")
    @Log(title = "产品库存", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inventoryIds}")
    public AjaxResult remove(@PathVariable Long[] inventoryIds)
    {
        return toAjax(sysSalesInventoryService.deleteSysSalesInventoryByInventoryIds(inventoryIds));
    }
}
